/*
 * @Author: your name
 * @Date: 2019-07-26 15:33:16
 * @LastEditTime: 2019-11-01 15:10:33
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \koa-example\src\app.js
 */
const Koa = require('koa');
const staticServer = require('koa-static');
// const mongoose = require('mongoose');
var Router = require('koa-router');
// const log4js = require('koa-log4');
const koaBody = require('koa-body');

const app = new Koa();
// 静态资源
app.use(staticServer(__dirname , 'static'));
const router = Router();

// koaBody必须放在router之前
app.use(koaBody());

const loginRouter = require('./routes/login.js');
const publicNewsRouter = require('./routes/public/publicNewsRouter.js');
// const publicNegativeParaRouter = require('./routes/public/publicNegativeParaRouter.js');
const questionsRouter = require('./routes/question/questionsRouter.js');
loginRouter(app);
publicNewsRouter(app);
// publicNegativeParaRouter(app);
questionsRouter(app);

app.use(router.routes()); //作用：启动路由
app.use(router.allowedMethods());



// app.use(log4js.koaLogger(log4js.getLogger("http"), { level: 'auto' }))
const PORT = 8888;
app.listen(PORT, function(){
  console.log(`服务启动成功，端口号：${PORT}` )
});